﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ReportBetLogSpin.aspx.cs" Inherits="CMS.ReportBetLogSpin" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI, Version=2009.1.311.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div style="font-size: 26px; font-weight: bold; text-align: center;">TRA CỨU LƯỢT QUAY</div>
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1">
        <div>
            <%--            Từ ngày :--%>
            <%--        <telerik:RadDatePicker ID="txtFromDate" runat="server" Skin="Default" DateInput-DateFormat="MM/dd/yyyy"--%>
            <%--            DateInput-DisplayDateFormat="dd/MM/yyyy">--%>
            <%--        </telerik:RadDatePicker>--%>
            <%--            Đến ngày :--%>
            <%--        <telerik:RadDatePicker ID="txtToDate" runat="server" Skin="Default" DateInput-DateFormat="MM/dd/yyyy"--%>
            <%--            DateInput-DisplayDateFormat="dd/MM/yyyy">--%>
            <%--        </telerik:RadDatePicker>--%>
            <asp:TextBox ID="txtBetLogID" runat="server" Text="0"></asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator1"
                ControlToValidate="txtBetLogID"
                ValidationExpression="\d+"
                Display="Static"
                EnableClientScript="true"
                ErrorMessage="Chỉ nhập số"
                runat="server" />
            <asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" />
        </div>
        <br />
        <asp:GridView ID="GridView1" DataKeyNames="BetLogID" runat="server" CellPadding="4" ForeColor="#333333" AllowPaging="True" PageSize="20" GridLines="None" Width="100%" AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging">
            <Columns>
                <asp:BoundField HeaderText="Lượt" DataField="BetLogID"></asp:BoundField>                
                <asp:BoundField HeaderText="Phòng" DataField="GameId"></asp:BoundField>
                <asp:BoundField HeaderText="Tiền cược" DataField="BetMoney" DataFormatString="{0:n0}"></asp:BoundField>               
                <asp:BoundField HeaderText="Số line cược" DataField="CountLineBet"></asp:BoundField>
                <asp:BoundField HeaderText="Tổng thắng" DataField="WinMoney" DataFormatString="{0:n0}"></asp:BoundField>
                <asp:BoundField HeaderText="Jackpot" DataField="Jackpot" DataFormatString="{0:n0}"></asp:BoundField>
                <asp:BoundField HeaderText="Đào vàng" DataField="DigGold" DataFormatString="{0:n0}"></asp:BoundField>
                <asp:BoundField HeaderText="Line thắng" DataField="LineWin"></asp:BoundField>
                <asp:BoundField HeaderText="Số line thắng" DataField="CountLineWin"></asp:BoundField>
                <asp:BoundField HeaderText="Ngày" DataField="TimeWin"></asp:BoundField>
                <asp:TemplateField HeaderText="Chi tiết">
                    <ItemTemplate>
                        <a href="javascript:;" onclick="javascript:showPopup(<%# Eval("BetLogID") %>)">Chi tiết</a>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        </asp:GridView>
        <asp:Literal runat="server" ID="ltOutput"></asp:Literal>

    </telerik:RadAjaxPanel>

 <script type="text/javascript">

     function showPopup(id) {
         CloseDialog();
         var width = 900;
         var height = 600;
         var content = '';
         var html = '';
         content += '<div style="overflow-y: scroll; height:560px; padding:10px; ">';
         content += '<div style="width:500px; margin:0 auto; font-size:24px; text-align:center; padding:10px;"><b>Kết quả quay</b></div>';
         $.ajax({
             type: "GET",
             url: "/ChartApi.ashx?t=detailsBetLog&id=" + id,
             contentType: "application/json; charset=utf-8",
             success: function (data) {
                 console.log(data);
                 var roomid = data.roomid;

                 var arrValues = data.result.substr(0, data.result.length - 1).split(',');
                 content += '<div style="width:610px; height:372px; margin:0 auto; background:url(Images/play' + roomid + '.png) no-repeat;">';
                 content += '<div style="width:565px; height:315px; margin:0px auto; padding-top: 56px;">';
                 $.each(arrValues, function (intIndex, objValue) {
                     content += '<img src="' + getImgById(objValue, roomid) + '" style="padding:3px 9px;" />';
                 });
                 content += '</div>';
                 content += '</div>';
                 if (data.bonnus != "") {
                     if (data.bonnus.split(',').length < 3) {
                         var bonnus = data.bonnus.substr(1, data.bonnus.length - 1);
                         bonnus = bonnus.substr(0, bonnus.length - 2);
                         var type = bonnus.split(":")[0];
                         var valueWin = bonnus.split(":")[1];
                         if (type == "1") {
                             content += '<div style="width:700px; margin:10px auto; font-size:20px;">Trúng Jackpot: ' + formatMoney(valueWin) + ' Sao</div>';
                         }
                         if (type == "2") {
                             content += '<div style="width:700px; margin:10px auto; font-size:20px;">Đào vàng: ' + formatMoney(valueWin) + ' Sao</div>';
                         }
                         if (type == "3") {
                             content += '<div style="width:700px; margin:10px auto; font-size:20px;">Lượt Free: ' + formatMoney(valueWin) + ' lần</div>';
                         }
                     } else {
                         var arr = data.bonnus.split(',');
                         for (var i = 0; i < arr.length; i++) {
                             if (arr[i] != "") {
                                 console.log(arr[i]); //{2:176000}
                                 bonnus = arr[i].substr(1, arr[i].length - 2);
                                 console.log(bonnus);
                                 type = bonnus.split(":")[0];
                                 valueWin = bonnus.split(":")[1];
                                 if (type == "1") {
                                     content += '<div style="width:700px; margin:10px auto; font-size:20px;">Trúng Jackpot: ' + formatMoney(valueWin) + ' Sao</div>';
                                 }
                                 if (type == "2") {
                                     content += '<div style="width:700px; margin:10px auto; font-size:20px;">Đào vàng: ' + formatMoney(valueWin) + ' Sao</div>';
                                 }
                                 if (type == "3") {
                                     content += '<div style="width:700px; margin:10px auto; font-size:20px;">Lượt Free: ' + formatMoney(valueWin) + ' lần</div>';
                                 }
                             }
                         }
                     }
                 }
                 if (data.jsondetail != "[]" && data.jsondetail != "") {
                     var resp = JSON.stringify(eval("(" + data.jsondetail + ")"));
                     content += '<ul class="bang_line">';
                     $.each($.parseJSON(resp), function (i, item) {
                         var winSao = '';
                         if (item.it == 1 && item.wi == 0)
                             winSao = '<b>Jackpot</b>';
                         else if (item.it == 2 && item.wi == 0)
                             winSao = '<b>Đào vàng</b>';
                         else if (item.it == 7 && item.wi == 0)
                             winSao = '<b>Lượt free</b>';
                         else
                             winSao = formatMoney(item.wi) + ' Sao';
                         content += '<li><a href="javascript:" class="line' + item.li + '" alt="1"></a> trúng x' + item.am + ': ' + winSao + '</li>';
                     });
                     content += '</ul>';
                 } else {
                     content += '<div style="text-align:center;"><b>Không có line nào trúng</b></div>';
                 }
                 content += '</div>';
                 html =
                     '<div id="Popup_Container" style="width:' + width + 'px; border:1px solid Gray; background:#fff;">' +
                     '<div  id="popup_nd">' +
                     '<div onclick="CloseDialog();" style="position:absolute;right:15px; cursor:pointer;width:45px;height:50px;float:right;top:15px;">Đóng</div>' +
                     '<div id="temPopup">' + content +
                     '</div></div></div>' +
                     '<div onclick="CloseDialog();"  id="overlay" class="overlay" style="width:100%; height:100%; position:fixed; top:0px;"></div>' +
                     '';

                 $('BODY').append(html);

                 $('#popup_nd').css('width', width);
                 $('#popup_nd').css('height', height);
                 var leftOffset = ($(window).width() - width) / 2;
                 var topOffset = ($(window).height() - height) / 2 + $(window).scrollTop();
                 $('#Popup_Container').css('left', leftOffset + "px");
                 $('#Popup_Container').css('z-index', 1300);
                 $('#Popup_Container').css("top", topOffset + "px");
                 $('#Popup_Container').css('position', 'absolute');
                 $('#overlay').css('height', $(document).height());
                 $('#overlay').show();
             }
         });
     }

     function CloseDialog() {
         $('#Popup_Container').remove();
         $('#overlay').remove();
         $('.popup').remove();
         $('.overlay').remove();
     }

     function getImgById(id, roomid) {
         var pathFolder = "Images/Room1";
         switch (roomid) {
             case 1:;
                 pathFolder = "Images/Room1";
                 break;
             case 2:
                 pathFolder = "Images/Room2";
                 break;
             case 3:
                 pathFolder = "Images/Room3";
                 break;
         }

         return pathFolder + "/" + id + ".png";
     }
     function formatMoney(argValue) {
         var _comma = (1 / 2 + '').charAt(1);
         var _digit = ',';
         if (_comma == ',') {
             _digit = ',';
         }

         var _sSign = "";
         if (argValue < 0) {
             _sSign = "-";
             argValue = -argValue;
         }
         var _sTemp = "" + argValue;
         var _index = _sTemp.indexOf(_comma);
         var _digitExt = "";
         if (_index != -1) {
             _digitExt = _sTemp.substring(_index + 1);
             _sTemp = _sTemp.substring(0, _index);
         }
         var _sReturn = "";
         while (_sTemp.length > 3) {
             _sReturn = _digit + _sTemp.substring(_sTemp.length - 3) + _sReturn;
             _sTemp = _sTemp.substring(0, _sTemp.length - 3);
         }
         _sReturn = _sSign + _sTemp + _sReturn;
         if (_digitExt.length > 0) {
             _sReturn += _comma + _digitExt;
         }
         return _sReturn;
     };

    </script>
</asp:Content>
